{
语法百题 解题报告：
 http://git.oschina.net/et0662/sznoi-grammar/ 
}
var
 a:array[0..10] of integer;
 b:array[0..10] of boolean;
 max,zz:integer;

procedure search(n:integer);
var
	i:integer;
begin
	if n=(zz+1) then
	begin
		for i:= 1 to zz do
			write(a[i],' ');
		writeln;
	end
	else
	begin
		for i:=1 to max do
		begin
			if (i>a[n-1]) and (b[i]=false) then
			begin
				b[i]:=true;
				a[n]:=i;
				search(n+1);
				b[i]:=false;
			end;
		end;
	end;
end;

begin
	readln(max, zz);
	search(1);
end.
